<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Key Value Storage (kv-store)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="logo.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Key Value Storage (kv-store)</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__group__kvstore.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Macros</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">Key Value Storage Library</div></div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<p >This library provides a convenient way to store information as key-value pairs in non-volatile storage. </p>
<h1><a class="anchor" id="section_kvstore_getting_started"></a>
Getting Started</h1>
<p >This section provides steps for getting started with this library by providing examples using the <a href="https://github.com/infineon/serial-flash">Serial Flash</a> (v1.X) and <a href="https://github.com/infineon/mtb-hal-cat1">HAL Flash driver</a> (v1.X) libraries. Note that this section assumes that the required libraries are already included in the application. For more information on how to include libaries in the application please refer to the <a href="https://www.cypress.com/products/modustoolbox-software-environment">ModusToolbox™ User Guide</a></p>
<ol type="1">
<li>Include the kv-store library header in the application. <div class="fragment"><div class="line"><span class="preprocessor">#include &quot;mtb_kvstore.h&quot;</span></div>
</div><!-- fragment --></li>
<li>Implement the block device interface. The following snippets can be copied into the application. If neither the serial-flash nor HAL flash driver is being used to communicate with the storage device, the application must provide a custom implementation of the block device interface.<ul>
<li>Example implementation using serial-flash library. <div class="fragment"><div class="line"><span class="preprocessor">#include &quot;cycfg_qspi_memslot.h&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;cy_serial_flash_qspi.h&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment">// bd_read_size</span></div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="keyword">static</span> uint32_t bd_read_size(<span class="keywordtype">void</span>* context, uint32_t addr)</div>
<div class="line">{</div>
<div class="line">    CY_UNUSED_PARAMETER(context);</div>
<div class="line">    CY_UNUSED_PARAMETER(addr);</div>
<div class="line">    <span class="keywordflow">return</span> 1;</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment">// bd_program_size</span></div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="keyword">static</span> uint32_t bd_program_size(<span class="keywordtype">void</span>* context, uint32_t addr)</div>
<div class="line">{</div>
<div class="line">    CY_UNUSED_PARAMETER(context);</div>
<div class="line">    <span class="keywordflow">return</span> cy_serial_flash_qspi_get_prog_size(addr);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment">// bd_erase_size</span></div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="keyword">static</span> uint32_t bd_erase_size(<span class="keywordtype">void</span>* context, uint32_t addr)</div>
<div class="line">{</div>
<div class="line">    CY_UNUSED_PARAMETER(context);</div>
<div class="line">    <span class="keywordflow">return</span> cy_serial_flash_qspi_get_erase_size(addr);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment">// bd_read</span></div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="keyword">static</span> cy_rslt_t bd_read(<span class="keywordtype">void</span>* context, uint32_t addr, uint32_t length, uint8_t* buf)</div>
<div class="line">{</div>
<div class="line">    CY_UNUSED_PARAMETER(context);</div>
<div class="line">    <span class="keywordflow">return</span> cy_serial_flash_qspi_read(addr, length, buf);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment">// bd_program</span></div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="keyword">static</span> cy_rslt_t bd_program(<span class="keywordtype">void</span>* context, uint32_t addr, uint32_t length, <span class="keyword">const</span> uint8_t* buf)</div>
<div class="line">{</div>
<div class="line">    CY_UNUSED_PARAMETER(context);</div>
<div class="line">    <span class="keywordflow">return</span> cy_serial_flash_qspi_write(addr, length, buf);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment">// bd_erase</span></div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="keyword">static</span> cy_rslt_t bd_erase(<span class="keywordtype">void</span>* context, uint32_t addr, uint32_t length)</div>
<div class="line">{</div>
<div class="line">    CY_UNUSED_PARAMETER(context);</div>
<div class="line">    <span class="keywordflow">return</span> cy_serial_flash_qspi_erase(addr, length);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> <a class="code hl_struct" href="group__group__kvstore.html#structmtb__kvstore__bd__t">mtb_kvstore_bd_t</a> block_device =</div>
<div class="line">{</div>
<div class="line">    .<a class="code hl_variable" href="group__group__kvstore.html#a405a94199e464120970faaaf987eb3af">read</a>         = bd_read,</div>
<div class="line">    .program      = bd_program,</div>
<div class="line">    .erase        = bd_erase,</div>
<div class="line">    .read_size    = bd_read_size,</div>
<div class="line">    .program_size = bd_program_size,</div>
<div class="line">    .erase_size   = bd_erase_size,</div>
<div class="line">    .context      = NULL</div>
<div class="line">};</div>
<div class="ttc" id="agroup__group__kvstore_html_a405a94199e464120970faaaf987eb3af"><div class="ttname"><a href="group__group__kvstore.html#a405a94199e464120970faaaf987eb3af">mtb_kvstore_bd_t::read</a></div><div class="ttdeci">mtb_kvstore_bd_read read</div><div class="ttdoc">Function to read from device.</div><div class="ttdef"><b>Definition:</b> mtb_kvstore.h:215</div></div>
<div class="ttc" id="agroup__group__kvstore_html_structmtb__kvstore__bd__t"><div class="ttname"><a href="group__group__kvstore.html#structmtb__kvstore__bd__t">mtb_kvstore_bd_t</a></div><div class="ttdoc">Block device interface.</div><div class="ttdef"><b>Definition:</b> mtb_kvstore.h:214</div></div>
</div><!-- fragment --></li>
<li>Example implementation using hal flash driver. <div class="fragment"><div class="line"><span class="preprocessor">#include &quot;cyhal.h&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> cyhal_flash_t flash_obj;</div>
<div class="line"><span class="keyword">static</span> cyhal_flash_block_info_t block_info;</div>
<div class="line"> </div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment">// bd_read_size</span></div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="keyword">static</span> uint32_t bd_read_size(<span class="keywordtype">void</span>* context, uint32_t addr)</div>
<div class="line">{</div>
<div class="line">    CY_UNUSED_PARAMETER(context);</div>
<div class="line">    CY_UNUSED_PARAMETER(addr);</div>
<div class="line">    <span class="keywordflow">return</span> 1;</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment">// bd_program_size</span></div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="keyword">static</span> uint32_t bd_program_size(<span class="keywordtype">void</span>* context, uint32_t addr)</div>
<div class="line">{</div>
<div class="line">    CY_UNUSED_PARAMETER(context);</div>
<div class="line">    CY_UNUSED_PARAMETER(addr);</div>
<div class="line">    <span class="keywordflow">return</span> block_info.page_size;</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment">// bd_erase_size</span></div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="keyword">static</span> uint32_t bd_erase_size(<span class="keywordtype">void</span>* context, uint32_t addr)</div>
<div class="line">{</div>
<div class="line">    CY_UNUSED_PARAMETER(context);</div>
<div class="line">    CY_UNUSED_PARAMETER(addr);</div>
<div class="line">    <span class="keywordflow">return</span> block_info.sector_size;</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment">// bd_read</span></div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="keyword">static</span> cy_rslt_t bd_read(<span class="keywordtype">void</span>* context, uint32_t addr, uint32_t length, uint8_t* buf)</div>
<div class="line">{</div>
<div class="line">    CY_UNUSED_PARAMETER(context);</div>
<div class="line">    memcpy(buf, (<span class="keyword">const</span> uint8_t*)(addr), length);</div>
<div class="line">    <span class="keywordflow">return</span> CY_RSLT_SUCCESS;</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment">// bd_program</span></div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="keyword">static</span> cy_rslt_t bd_program(<span class="keywordtype">void</span>* context, uint32_t addr, uint32_t length, <span class="keyword">const</span> uint8_t* buf)</div>
<div class="line">{</div>
<div class="line">    uint32_t prog_size = bd_program_size(context, addr);</div>
<div class="line">    CY_ASSERT(0 == (length % prog_size));</div>
<div class="line"> </div>
<div class="line">    <span class="keyword">volatile</span> cy_rslt_t result = CY_RSLT_SUCCESS;</div>
<div class="line">    <span class="keywordflow">for</span> (uint32_t loc = addr; result == CY_RSLT_SUCCESS &amp;&amp; loc &lt; addr + length;</div>
<div class="line">         loc += prog_size, buf += prog_size)</div>
<div class="line">    {</div>
<div class="line">        result = cyhal_flash_program((cyhal_flash_t*)context, loc, (<span class="keyword">const</span> uint32_t*)buf);</div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">return</span> result;</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment">// bd_erase</span></div>
<div class="line"><span class="comment">//--------------------------------------------------------------------------------------------------</span></div>
<div class="line"><span class="keyword">static</span> cy_rslt_t bd_erase(<span class="keywordtype">void</span>* context, uint32_t addr, uint32_t length)</div>
<div class="line">{</div>
<div class="line">    uint32_t erase_size = bd_erase_size(context, addr);</div>
<div class="line">    CY_ASSERT(0 == (length % erase_size));</div>
<div class="line"> </div>
<div class="line">    cy_rslt_t result = CY_RSLT_SUCCESS;</div>
<div class="line">    <span class="keywordflow">for</span> (uint32_t loc = addr; result == CY_RSLT_SUCCESS &amp;&amp; loc &lt; addr + length; loc += erase_size)</div>
<div class="line">    {</div>
<div class="line">        result = cyhal_flash_erase((cyhal_flash_t*)context, loc);</div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">return</span> result;</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> <a class="code hl_struct" href="group__group__kvstore.html#structmtb__kvstore__bd__t">mtb_kvstore_bd_t</a> block_device =</div>
<div class="line">{</div>
<div class="line">    .<a class="code hl_variable" href="group__group__kvstore.html#a405a94199e464120970faaaf987eb3af">read</a>         = bd_read,</div>
<div class="line">    .program      = bd_program,</div>
<div class="line">    .erase        = bd_erase,</div>
<div class="line">    .read_size    = bd_read_size,</div>
<div class="line">    .program_size = bd_program_size,</div>
<div class="line">    .erase_size   = bd_erase_size,</div>
<div class="line">    .context      = &amp;flash_obj</div>
<div class="line">};</div>
</div><!-- fragment --></li>
</ul>
</li>
<li>Initialize the block device.<ul>
<li>Example initialization for serial-flash library. This example configures the serial-flash using the memory configuration from the BSP. Please refer to the serial-flash <a href="https://infineon.github.io/serial-flash/html/index.html">API Reference Guide</a> for further details. <div class="fragment"><div class="line">    <span class="keyword">const</span> uint32_t qspi_bus_freq_hz = 50000000lu;</div>
<div class="line">    cy_rslt_t result = cy_serial_flash_qspi_init(smifMemConfigs[0], CYBSP_QSPI_D0,</div>
<div class="line">                                                 CYBSP_QSPI_D1, CYBSP_QSPI_D2, CYBSP_QSPI_D3, NC,</div>
<div class="line">                                                 NC, NC, NC,</div>
<div class="line">                                                 CYBSP_QSPI_SCK, CYBSP_QSPI_SS, qspi_bus_freq_hz);</div>
<div class="line">    CY_ASSERT(result == CY_RSLT_SUCCESS);</div>
</div><!-- fragment --></li>
<li>Example initialization for hal flash driver. This example initializes the working flash if available otherwise it initializes the main flash. Please refer to the HAL <a href="https://infineon.github.io/mtb-hal-cat1/html/modules.html">API Reference Guide</a> for further details. <div class="fragment"><div class="line">    cy_rslt_t result = cyhal_flash_init(&amp;flash_obj);</div>
<div class="line">    CY_ASSERT(result == CY_RSLT_SUCCESS);</div>
<div class="line">    cyhal_flash_info_t flash_info;</div>
<div class="line">    cyhal_flash_get_info(&amp;flash_obj, &amp;flash_info);</div>
<div class="line">    block_info = flash_info.blocks[flash_info.block_count - 1];</div>
</div><!-- fragment --></li>
</ul>
</li>
<li>Initialize the kv-store library.<ul>
<li>Set the start address and length.<ul>
<li>If using the serial-flash library, for this example we define the space provided to the kv-store library to be the size of 2 sectors. <div class="fragment"><div class="line">    uint32_t sector_size = cy_serial_flash_qspi_get_erase_size(0);</div>
<div class="line">    uint32_t length = sector_size * 2;</div>
<div class="line">    uint32_t start_addr = 0;</div>
</div><!-- fragment --></li>
<li>If using the hal flash driver, for this example the address space provided starts 16 pages from the end of the flash. Note that if the device does not have a working flash (i.e. using main flash) care must be taken to ensure that the space allocated below is not used by anything (for eg. Application image). <div class="fragment"><div class="line">    uint32_t length = 16U * block_info.page_size;</div>
<div class="line">    uint32_t start_addr = block_info.start_address + block_info.size - length;</div>
</div><!-- fragment --></li>
</ul>
</li>
<li>Call <a class="el" href="group__group__kvstore.html#ga51e164317709c8d0c02fc07d87e4e780">mtb_kvstore_init</a> by passing the start address, length and block device. <div class="fragment"><div class="line">    mtb_kvstore_t obj;</div>
<div class="line">    result = <a class="code hl_function" href="group__group__kvstore.html#ga51e164317709c8d0c02fc07d87e4e780">mtb_kvstore_init</a>(&amp;obj, start_addr, length, &amp;block_device);</div>
<div class="line">    CY_ASSERT(result == CY_RSLT_SUCCESS);</div>
<div class="ttc" id="agroup__group__kvstore_html_ga51e164317709c8d0c02fc07d87e4e780"><div class="ttname"><a href="group__group__kvstore.html#ga51e164317709c8d0c02fc07d87e4e780">mtb_kvstore_init</a></div><div class="ttdeci">cy_rslt_t mtb_kvstore_init(mtb_kvstore_t *obj, uint32_t start_addr, uint32_t length, const mtb_kvstore_bd_t *block_device)</div><div class="ttdoc">Initialize a instance kv-store library.</div><div class="ttdef"><b>Definition:</b> mtb_kvstore.c:1518</div></div>
</div><!-- fragment --></li>
</ul>
</li>
<li>The library should now be ready to perform operations.<ul>
<li>Write operation. <div class="fragment"><div class="line">    uint8_t data[10];</div>
<div class="line">    result = <a class="code hl_function" href="group__group__kvstore.html#ga209eef7f4603173449de48d3d4775835">mtb_kvstore_write</a>(&amp;obj, <span class="stringliteral">&quot;hello&quot;</span>, data, <span class="keyword">sizeof</span>(data));</div>
<div class="line">    CY_ASSERT(result == CY_RSLT_SUCCESS);</div>
<div class="ttc" id="agroup__group__kvstore_html_ga209eef7f4603173449de48d3d4775835"><div class="ttname"><a href="group__group__kvstore.html#ga209eef7f4603173449de48d3d4775835">mtb_kvstore_write</a></div><div class="ttdeci">cy_rslt_t mtb_kvstore_write(mtb_kvstore_t *obj, const char *key, const uint8_t *data, uint32_t size)</div><div class="ttdoc">Store a key value pair.</div><div class="ttdef"><b>Definition:</b> mtb_kvstore.c:1607</div></div>
</div><!-- fragment --></li>
<li>Read operation. <div class="fragment"><div class="line">    uint8_t read_data[10];</div>
<div class="line">    uint32_t data_size = <span class="keyword">sizeof</span>(read_data);</div>
<div class="line">    result = <a class="code hl_function" href="group__group__kvstore.html#gad2327026f8f741835d012aa0a1f60f14">mtb_kvstore_read</a>(&amp;obj, <span class="stringliteral">&quot;hello&quot;</span>, read_data, &amp;data_size);</div>
<div class="line">    CY_ASSERT(result == CY_RSLT_SUCCESS);</div>
<div class="ttc" id="agroup__group__kvstore_html_gad2327026f8f741835d012aa0a1f60f14"><div class="ttname"><a href="group__group__kvstore.html#gad2327026f8f741835d012aa0a1f60f14">mtb_kvstore_read</a></div><div class="ttdeci">cy_rslt_t mtb_kvstore_read(mtb_kvstore_t *obj, const char *key, uint8_t *data, uint32_t *size)</div><div class="ttdoc">Read data associated with a key.</div><div class="ttdef"><b>Definition:</b> mtb_kvstore.c:1689</div></div>
</div><!-- fragment --></li>
<li>Delete operation. <div class="fragment"><div class="line">    result = <a class="code hl_function" href="group__group__kvstore.html#gafb22467328e29fd0b881eae93679a0f9">mtb_kvstore_delete</a>(&amp;obj, <span class="stringliteral">&quot;hello&quot;</span>);</div>
<div class="line">    CY_ASSERT(result == CY_RSLT_SUCCESS);</div>
<div class="ttc" id="agroup__group__kvstore_html_gafb22467328e29fd0b881eae93679a0f9"><div class="ttname"><a href="group__group__kvstore.html#gafb22467328e29fd0b881eae93679a0f9">mtb_kvstore_delete</a></div><div class="ttdeci">cy_rslt_t mtb_kvstore_delete(mtb_kvstore_t *obj, const char *key)</div><div class="ttdoc">Delete a key value pair.</div><div class="ttdef"><b>Definition:</b> mtb_kvstore.c:1814</div></div>
</div><!-- fragment --> </li>
</ul>
</li>
</ol>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:structmtb__kvstore__bd__t"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#structmtb__kvstore__bd__t">mtb_kvstore_bd_t</a></td></tr>
<tr class="memdesc:structmtb__kvstore__bd__t"><td class="mdescLeft">&#160;</td><td class="mdescRight">Block device interface.  <a href="group__group__kvstore.html#structmtb__kvstore__bd__t">More...</a><br /></td></tr>
<tr class="separator:structmtb__kvstore__bd__t"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga23dc5337825e5abb56afd1938b41e997"><td class="memItemLeft" align="right" valign="top"><a id="ga23dc5337825e5abb56afd1938b41e997" name="ga23dc5337825e5abb56afd1938b41e997"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>MTB_KVSTORE_MAX_KEY_SIZE</b>&#160;&#160;&#160;(64U)</td></tr>
<tr class="memdesc:ga23dc5337825e5abb56afd1938b41e997"><td class="mdescLeft">&#160;</td><td class="mdescRight">Maximum key size permitted. <br /></td></tr>
<tr class="separator:ga23dc5337825e5abb56afd1938b41e997"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab15b7f2a1cea77f4621f72c8082ae352"><td class="memItemLeft" align="right" valign="top"><a id="gab15b7f2a1cea77f4621f72c8082ae352" name="gab15b7f2a1cea77f4621f72c8082ae352"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>MTB_KVSTORE_ENSURE_MAX</b>&#160;&#160;&#160;(0xFFFFFFFFu)</td></tr>
<tr class="memdesc:gab15b7f2a1cea77f4621f72c8082ae352"><td class="mdescLeft">&#160;</td><td class="mdescRight">When passed as an argument to <a class="el" href="group__group__kvstore.html#gad0c50e719da0063d48d9d6224d22c756">mtb_kvstore_ensure_capacity</a>, indicates that cleanup tasks should always be performed regardless of the amount of space which is currently free, to ensure the maximum possible amount of free space is available. <br /></td></tr>
<tr class="separator:gab15b7f2a1cea77f4621f72c8082ae352"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf080d74c7e7cd0b04649ce6617831e74"><td class="memItemLeft" align="right" valign="top"><a id="gaf080d74c7e7cd0b04649ce6617831e74" name="gaf080d74c7e7cd0b04649ce6617831e74"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>MTB_KVSTORE_BAD_PARAM_ERROR</b>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 0)</td></tr>
<tr class="memdesc:gaf080d74c7e7cd0b04649ce6617831e74"><td class="mdescLeft">&#160;</td><td class="mdescRight">An invalid parameter value is passed in. <br /></td></tr>
<tr class="separator:gaf080d74c7e7cd0b04649ce6617831e74"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4513227045ee358f8f2622c8cf0a3485"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga4513227045ee358f8f2622c8cf0a3485">MTB_KVSTORE_ALIGNMENT_ERROR</a>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 1)</td></tr>
<tr class="memdesc:ga4513227045ee358f8f2622c8cf0a3485"><td class="mdescLeft">&#160;</td><td class="mdescRight">The storage area passed in is not aligned to erase sector boundary.  <a href="group__group__kvstore.html#ga4513227045ee358f8f2622c8cf0a3485">More...</a><br /></td></tr>
<tr class="separator:ga4513227045ee358f8f2622c8cf0a3485"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa4476b5e7db68726ae74b0153690fbfc"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gaa4476b5e7db68726ae74b0153690fbfc">MTB_KVSTORE_MEM_ALLOC_ERROR</a>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 2)</td></tr>
<tr class="memdesc:gaa4476b5e7db68726ae74b0153690fbfc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Memory allocation failed.  <a href="group__group__kvstore.html#gaa4476b5e7db68726ae74b0153690fbfc">More...</a><br /></td></tr>
<tr class="separator:gaa4476b5e7db68726ae74b0153690fbfc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga231945421777b158f99b21e5bc2ffde0"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga231945421777b158f99b21e5bc2ffde0">MTB_KVSTORE_INVALID_DATA_ERROR</a>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 3)</td></tr>
<tr class="memdesc:ga231945421777b158f99b21e5bc2ffde0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Invalid data was detected.  <a href="group__group__kvstore.html#ga231945421777b158f99b21e5bc2ffde0">More...</a><br /></td></tr>
<tr class="separator:ga231945421777b158f99b21e5bc2ffde0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga531cd29dc9167444df1474d15a9e263f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga531cd29dc9167444df1474d15a9e263f">MTB_KVSTORE_ERASED_DATA_ERROR</a>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 4)</td></tr>
<tr class="memdesc:ga531cd29dc9167444df1474d15a9e263f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Erased data was detected.  <a href="group__group__kvstore.html#ga531cd29dc9167444df1474d15a9e263f">More...</a><br /></td></tr>
<tr class="separator:ga531cd29dc9167444df1474d15a9e263f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0b1535ec72da31cca2681a2990d69d60"><td class="memItemLeft" align="right" valign="top"><a id="ga0b1535ec72da31cca2681a2990d69d60" name="ga0b1535ec72da31cca2681a2990d69d60"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>MTB_KVSTORE_ITEM_NOT_FOUND_ERROR</b>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 5)</td></tr>
<tr class="memdesc:ga0b1535ec72da31cca2681a2990d69d60"><td class="mdescLeft">&#160;</td><td class="mdescRight">Item was not found in the storage. <br /></td></tr>
<tr class="separator:ga0b1535ec72da31cca2681a2990d69d60"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf746e26fd8da70e4169614b530371a65"><td class="memItemLeft" align="right" valign="top"><a id="gaf746e26fd8da70e4169614b530371a65" name="gaf746e26fd8da70e4169614b530371a65"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>MTB_KVSTORE_STORAGE_FULL_ERROR</b>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 6)</td></tr>
<tr class="memdesc:gaf746e26fd8da70e4169614b530371a65"><td class="mdescLeft">&#160;</td><td class="mdescRight">The storage is full. <br /></td></tr>
<tr class="separator:gaf746e26fd8da70e4169614b530371a65"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3b7ec8bfe496de11d5961eddf55eb8a8"><td class="memItemLeft" align="right" valign="top"><a id="ga3b7ec8bfe496de11d5961eddf55eb8a8" name="ga3b7ec8bfe496de11d5961eddf55eb8a8"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>MTB_KVSTORE_BUFFER_TOO_SMALL</b>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 7)</td></tr>
<tr class="memdesc:ga3b7ec8bfe496de11d5961eddf55eb8a8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Buffer provided is too small for value found. <br /></td></tr>
<tr class="separator:ga3b7ec8bfe496de11d5961eddf55eb8a8"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:gacccba62e614b1ebb309dc312b7b67e3a"><td class="memItemLeft" align="right" valign="top">typedef cy_rslt_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gacccba62e614b1ebb309dc312b7b67e3a">mtb_kvstore_bd_read</a>) (void *context, uint32_t addr, uint32_t length, uint8_t *buf)</td></tr>
<tr class="memdesc:gacccba62e614b1ebb309dc312b7b67e3a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function prototype for reading data from the block device.  <a href="group__group__kvstore.html#gacccba62e614b1ebb309dc312b7b67e3a">More...</a><br /></td></tr>
<tr class="separator:gacccba62e614b1ebb309dc312b7b67e3a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa832bac0e2f7b15478abb73ae8631b8d"><td class="memItemLeft" align="right" valign="top">typedef cy_rslt_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gaa832bac0e2f7b15478abb73ae8631b8d">mtb_kvstore_bd_program</a>) (void *context, uint32_t addr, uint32_t length, const uint8_t *buf)</td></tr>
<tr class="memdesc:gaa832bac0e2f7b15478abb73ae8631b8d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function prototype for writing data to the block device.  <a href="group__group__kvstore.html#gaa832bac0e2f7b15478abb73ae8631b8d">More...</a><br /></td></tr>
<tr class="separator:gaa832bac0e2f7b15478abb73ae8631b8d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8eee071bb3809130b77fb7c8f69e7a67"><td class="memItemLeft" align="right" valign="top">typedef cy_rslt_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga8eee071bb3809130b77fb7c8f69e7a67">mtb_kvstore_bd_erase</a>) (void *context, uint32_t addr, uint32_t length)</td></tr>
<tr class="memdesc:ga8eee071bb3809130b77fb7c8f69e7a67"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function prototype for read from the block device.  <a href="group__group__kvstore.html#ga8eee071bb3809130b77fb7c8f69e7a67">More...</a><br /></td></tr>
<tr class="separator:ga8eee071bb3809130b77fb7c8f69e7a67"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4d03d5b99d6254298f9eaefb0978170f"><td class="memItemLeft" align="right" valign="top">typedef uint32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga4d03d5b99d6254298f9eaefb0978170f">mtb_kvstore_bd_read_size</a>) (void *context, uint32_t addr)</td></tr>
<tr class="memdesc:ga4d03d5b99d6254298f9eaefb0978170f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function prototype to get the read size of the block device for a specific address.  <a href="group__group__kvstore.html#ga4d03d5b99d6254298f9eaefb0978170f">More...</a><br /></td></tr>
<tr class="separator:ga4d03d5b99d6254298f9eaefb0978170f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga33782352587721d63e4ca26f35558d90"><td class="memItemLeft" align="right" valign="top">typedef uint32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga33782352587721d63e4ca26f35558d90">mtb_kvstore_bd_program_size</a>) (void *context, uint32_t addr)</td></tr>
<tr class="memdesc:ga33782352587721d63e4ca26f35558d90"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function prototype to get the program size of the block device for a specific address.  <a href="group__group__kvstore.html#ga33782352587721d63e4ca26f35558d90">More...</a><br /></td></tr>
<tr class="separator:ga33782352587721d63e4ca26f35558d90"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9dcd451cefcdae7d7063aa2e173b948b"><td class="memItemLeft" align="right" valign="top">typedef uint32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga9dcd451cefcdae7d7063aa2e173b948b">mtb_kvstore_bd_erase_size</a>) (void *context, uint32_t addr)</td></tr>
<tr class="memdesc:ga9dcd451cefcdae7d7063aa2e173b948b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function prototype to get the erase size of the block device for a specific address.  <a href="group__group__kvstore.html#ga9dcd451cefcdae7d7063aa2e173b948b">More...</a><br /></td></tr>
<tr class="separator:ga9dcd451cefcdae7d7063aa2e173b948b"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga51e164317709c8d0c02fc07d87e4e780"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga51e164317709c8d0c02fc07d87e4e780">mtb_kvstore_init</a> (mtb_kvstore_t *obj, uint32_t start_addr, uint32_t length, const <a class="el" href="group__group__kvstore.html#structmtb__kvstore__bd__t">mtb_kvstore_bd_t</a> *block_device)</td></tr>
<tr class="memdesc:ga51e164317709c8d0c02fc07d87e4e780"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize a instance kv-store library.  <a href="group__group__kvstore.html#ga51e164317709c8d0c02fc07d87e4e780">More...</a><br /></td></tr>
<tr class="separator:ga51e164317709c8d0c02fc07d87e4e780"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga209eef7f4603173449de48d3d4775835"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga209eef7f4603173449de48d3d4775835">mtb_kvstore_write</a> (mtb_kvstore_t *obj, const char *key, const uint8_t *data, uint32_t size)</td></tr>
<tr class="memdesc:ga209eef7f4603173449de48d3d4775835"><td class="mdescLeft">&#160;</td><td class="mdescRight">Store a key value pair.  <a href="group__group__kvstore.html#ga209eef7f4603173449de48d3d4775835">More...</a><br /></td></tr>
<tr class="separator:ga209eef7f4603173449de48d3d4775835"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad2327026f8f741835d012aa0a1f60f14"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gad2327026f8f741835d012aa0a1f60f14">mtb_kvstore_read</a> (mtb_kvstore_t *obj, const char *key, uint8_t *data, uint32_t *size)</td></tr>
<tr class="memdesc:gad2327026f8f741835d012aa0a1f60f14"><td class="mdescLeft">&#160;</td><td class="mdescRight">Read data associated with a key.  <a href="group__group__kvstore.html#gad2327026f8f741835d012aa0a1f60f14">More...</a><br /></td></tr>
<tr class="separator:gad2327026f8f741835d012aa0a1f60f14"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gadd5125b0adf2ef5a4afc39851aeaa288"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gadd5125b0adf2ef5a4afc39851aeaa288">mtb_kvstore_read_partial</a> (mtb_kvstore_t *obj, const char *key, uint8_t *data, uint32_t *size, const uint32_t offset_bytes)</td></tr>
<tr class="memdesc:gadd5125b0adf2ef5a4afc39851aeaa288"><td class="mdescLeft">&#160;</td><td class="mdescRight">Read data associated with a key.  <a href="group__group__kvstore.html#gadd5125b0adf2ef5a4afc39851aeaa288">More...</a><br /></td></tr>
<tr class="separator:gadd5125b0adf2ef5a4afc39851aeaa288"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga16b0bc2c58f9a4259d295746df43c8ad"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga16b0bc2c58f9a4259d295746df43c8ad">mtb_kvstore_key_exists</a> (mtb_kvstore_t *obj, const char *key)</td></tr>
<tr class="memdesc:ga16b0bc2c58f9a4259d295746df43c8ad"><td class="mdescLeft">&#160;</td><td class="mdescRight">Check if a key is stored in memory.  <a href="group__group__kvstore.html#ga16b0bc2c58f9a4259d295746df43c8ad">More...</a><br /></td></tr>
<tr class="separator:ga16b0bc2c58f9a4259d295746df43c8ad"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafd3c856a28b4a326f6e2982f0d18b6dc"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gafd3c856a28b4a326f6e2982f0d18b6dc">mtb_kvstore_value_size</a> (mtb_kvstore_t *obj, const char *key, uint32_t *size)</td></tr>
<tr class="memdesc:gafd3c856a28b4a326f6e2982f0d18b6dc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the size in bytes of data in memory corresponding to a given key.  <a href="group__group__kvstore.html#gafd3c856a28b4a326f6e2982f0d18b6dc">More...</a><br /></td></tr>
<tr class="separator:gafd3c856a28b4a326f6e2982f0d18b6dc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafb22467328e29fd0b881eae93679a0f9"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gafb22467328e29fd0b881eae93679a0f9">mtb_kvstore_delete</a> (mtb_kvstore_t *obj, const char *key)</td></tr>
<tr class="memdesc:gafb22467328e29fd0b881eae93679a0f9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Delete a key value pair.  <a href="group__group__kvstore.html#gafb22467328e29fd0b881eae93679a0f9">More...</a><br /></td></tr>
<tr class="separator:gafb22467328e29fd0b881eae93679a0f9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga543e217c6dad81778e1fc9926e28f23f"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga543e217c6dad81778e1fc9926e28f23f">mtb_kvstore_size</a> (mtb_kvstore_t *obj)</td></tr>
<tr class="memdesc:ga543e217c6dad81778e1fc9926e28f23f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Query the size consumed in the kv-store storage.  <a href="group__group__kvstore.html#ga543e217c6dad81778e1fc9926e28f23f">More...</a><br /></td></tr>
<tr class="separator:ga543e217c6dad81778e1fc9926e28f23f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga51591921642d49be5e5c8a9814bebd39"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga51591921642d49be5e5c8a9814bebd39">mtb_kvstore_remaining_size</a> (mtb_kvstore_t *obj)</td></tr>
<tr class="memdesc:ga51591921642d49be5e5c8a9814bebd39"><td class="mdescLeft">&#160;</td><td class="mdescRight">Query the free space available in the kv-store storage.  <a href="group__group__kvstore.html#ga51591921642d49be5e5c8a9814bebd39">More...</a><br /></td></tr>
<tr class="separator:ga51591921642d49be5e5c8a9814bebd39"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad0c50e719da0063d48d9d6224d22c756"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gad0c50e719da0063d48d9d6224d22c756">mtb_kvstore_ensure_capacity</a> (mtb_kvstore_t *obj, uint32_t size)</td></tr>
<tr class="memdesc:gad0c50e719da0063d48d9d6224d22c756"><td class="mdescLeft">&#160;</td><td class="mdescRight">Tries to make the specified amount of space available for immediate use.  <a href="group__group__kvstore.html#gad0c50e719da0063d48d9d6224d22c756">More...</a><br /></td></tr>
<tr class="separator:gad0c50e719da0063d48d9d6224d22c756"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5dc849717a6e3c8b7803fe2224cc6df1"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga5dc849717a6e3c8b7803fe2224cc6df1">mtb_kvstore_reset</a> (mtb_kvstore_t *obj)</td></tr>
<tr class="memdesc:ga5dc849717a6e3c8b7803fe2224cc6df1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reset kv-store storage.  <a href="group__group__kvstore.html#ga5dc849717a6e3c8b7803fe2224cc6df1">More...</a><br /></td></tr>
<tr class="separator:ga5dc849717a6e3c8b7803fe2224cc6df1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4388f0dd869ef9dbe2da0d2920cca290"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga4388f0dd869ef9dbe2da0d2920cca290">mtb_kvstore_deinit</a> (mtb_kvstore_t *obj)</td></tr>
<tr class="memdesc:ga4388f0dd869ef9dbe2da0d2920cca290"><td class="mdescLeft">&#160;</td><td class="mdescRight">Delete kv-store instance.  <a href="group__group__kvstore.html#ga4388f0dd869ef9dbe2da0d2920cca290">More...</a><br /></td></tr>
<tr class="separator:ga4388f0dd869ef9dbe2da0d2920cca290"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<hr/><h2 class="groupheader">Data Structure Documentation</h2>
<a name="structmtb__kvstore__bd__t" id="structmtb__kvstore__bd__t"></a>
<h2 class="memtitle"><span class="permalink"><a href="#structmtb__kvstore__bd__t">&#9670;&nbsp;</a></span>mtb_kvstore_bd_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct mtb_kvstore_bd_t</td>
        </tr>
      </table>
</div><div class="memdoc">
<table class="fieldtable">
<tr><th colspan="3">Data Fields</th></tr>
<tr><td class="fieldtype">
<a id="a405a94199e464120970faaaf987eb3af" name="a405a94199e464120970faaaf987eb3af"></a><a class="el" href="group__group__kvstore.html#gacccba62e614b1ebb309dc312b7b67e3a">mtb_kvstore_bd_read</a></td>
<td class="fieldname">
read</td>
<td class="fielddoc">
Function to read from device. </td></tr>
<tr><td class="fieldtype">
<a id="a20a7a7fa9739cec6774df53253f0aaa1" name="a20a7a7fa9739cec6774df53253f0aaa1"></a><a class="el" href="group__group__kvstore.html#gaa832bac0e2f7b15478abb73ae8631b8d">mtb_kvstore_bd_program</a></td>
<td class="fieldname">
program</td>
<td class="fielddoc">
Function to program to device. </td></tr>
<tr><td class="fieldtype">
<a id="a368ba3f8a7911728bcab952f02dc077b" name="a368ba3f8a7911728bcab952f02dc077b"></a><a class="el" href="group__group__kvstore.html#ga8eee071bb3809130b77fb7c8f69e7a67">mtb_kvstore_bd_erase</a></td>
<td class="fieldname">
erase</td>
<td class="fielddoc">
Function to erase device. </td></tr>
<tr><td class="fieldtype">
<a id="aa376bb68ef78eadbfdae534bb907d5cc" name="aa376bb68ef78eadbfdae534bb907d5cc"></a><a class="el" href="group__group__kvstore.html#ga4d03d5b99d6254298f9eaefb0978170f">mtb_kvstore_bd_read_size</a></td>
<td class="fieldname">
read_size</td>
<td class="fielddoc">
Function to get read size for an address. </td></tr>
<tr><td class="fieldtype">
<a id="a25c8c8c088ae475b1061e012e889d9b9" name="a25c8c8c088ae475b1061e012e889d9b9"></a><a class="el" href="group__group__kvstore.html#ga33782352587721d63e4ca26f35558d90">mtb_kvstore_bd_program_size</a></td>
<td class="fieldname">
program_size</td>
<td class="fielddoc">
Function to get program size for an address. </td></tr>
<tr><td class="fieldtype">
<a id="af2af1f47472f73b9c96068cd999a956b" name="af2af1f47472f73b9c96068cd999a956b"></a><a class="el" href="group__group__kvstore.html#ga9dcd451cefcdae7d7063aa2e173b948b">mtb_kvstore_bd_erase_size</a></td>
<td class="fieldname">
erase_size</td>
<td class="fielddoc">
Function to get erase size for an address. </td></tr>
<tr><td class="fieldtype">
<a id="a078caa17ea25e2109a6e25c92cb105cb" name="a078caa17ea25e2109a6e25c92cb105cb"></a>void *</td>
<td class="fieldname">
context</td>
<td class="fielddoc">
Context object that can be used in the block device implementation. </td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a id="ga4513227045ee358f8f2622c8cf0a3485" name="ga4513227045ee358f8f2622c8cf0a3485"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4513227045ee358f8f2622c8cf0a3485">&#9670;&nbsp;</a></span>MTB_KVSTORE_ALIGNMENT_ERROR</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MTB_KVSTORE_ALIGNMENT_ERROR&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 1)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The storage area passed in is not aligned to erase sector boundary. </p>
<p >See notes in <a class="el" href="group__group__kvstore.html#ga51e164317709c8d0c02fc07d87e4e780">mtb_kvstore_init</a> for more information on constraints. </p>

</div>
</div>
<a id="gaa4476b5e7db68726ae74b0153690fbfc" name="gaa4476b5e7db68726ae74b0153690fbfc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa4476b5e7db68726ae74b0153690fbfc">&#9670;&nbsp;</a></span>MTB_KVSTORE_MEM_ALLOC_ERROR</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MTB_KVSTORE_MEM_ALLOC_ERROR&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 2)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Memory allocation failed. </p>
<p >There is not enough space available on the heap. </p>

</div>
</div>
<a id="ga231945421777b158f99b21e5bc2ffde0" name="ga231945421777b158f99b21e5bc2ffde0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga231945421777b158f99b21e5bc2ffde0">&#9670;&nbsp;</a></span>MTB_KVSTORE_INVALID_DATA_ERROR</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MTB_KVSTORE_INVALID_DATA_ERROR&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 3)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Invalid data was detected. </p>
<p >The record may be corrupted. </p>

</div>
</div>
<a id="ga531cd29dc9167444df1474d15a9e263f" name="ga531cd29dc9167444df1474d15a9e263f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga531cd29dc9167444df1474d15a9e263f">&#9670;&nbsp;</a></span>MTB_KVSTORE_ERASED_DATA_ERROR</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MTB_KVSTORE_ERASED_DATA_ERROR&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 4)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Erased data was detected. </p>
<p >The record may be corrupted </p>

</div>
</div>
<h2 class="groupheader">Typedef Documentation</h2>
<a id="gacccba62e614b1ebb309dc312b7b67e3a" name="gacccba62e614b1ebb309dc312b7b67e3a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacccba62e614b1ebb309dc312b7b67e3a">&#9670;&nbsp;</a></span>mtb_kvstore_bd_read</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef cy_rslt_t(* mtb_kvstore_bd_read) (void *context, uint32_t addr, uint32_t length, uint8_t *buf)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Function prototype for reading data from the block device. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">context</td><td>Context object that is passed into <a class="el" href="group__group__kvstore.html#ga51e164317709c8d0c02fc07d87e4e780">mtb_kvstore_init</a> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>Address to read the data from the block device. This address is passed in as start_addr + offset. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">length</td><td>Length of the data that needs to be read. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">buf</td><td>Buffer to read the data. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the read operation. </dd></dl>

</div>
</div>
<a id="gaa832bac0e2f7b15478abb73ae8631b8d" name="gaa832bac0e2f7b15478abb73ae8631b8d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa832bac0e2f7b15478abb73ae8631b8d">&#9670;&nbsp;</a></span>mtb_kvstore_bd_program</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef cy_rslt_t(* mtb_kvstore_bd_program) (void *context, uint32_t addr, uint32_t length, const uint8_t *buf)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Function prototype for writing data to the block device. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">context</td><td>Context object that is passed into <a class="el" href="group__group__kvstore.html#ga51e164317709c8d0c02fc07d87e4e780">mtb_kvstore_init</a> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>Address to program the data into the block device. This address is passed in as start_addr + offset. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">length</td><td>Length of the data that needs to be written </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">buf</td><td>Data that needs to be written </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the program operation. </dd></dl>

</div>
</div>
<a id="ga8eee071bb3809130b77fb7c8f69e7a67" name="ga8eee071bb3809130b77fb7c8f69e7a67"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga8eee071bb3809130b77fb7c8f69e7a67">&#9670;&nbsp;</a></span>mtb_kvstore_bd_erase</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef cy_rslt_t(* mtb_kvstore_bd_erase) (void *context, uint32_t addr, uint32_t length)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Function prototype for read from the block device. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">context</td><td>Context object that is passed into <a class="el" href="group__group__kvstore.html#ga51e164317709c8d0c02fc07d87e4e780">mtb_kvstore_init</a> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>Address to read the data from the device. This address is passed in as start_addr + offset. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">length</td><td>Length of the data that needs to be erased. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the erase operation. </dd></dl>

</div>
</div>
<a id="ga4d03d5b99d6254298f9eaefb0978170f" name="ga4d03d5b99d6254298f9eaefb0978170f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4d03d5b99d6254298f9eaefb0978170f">&#9670;&nbsp;</a></span>mtb_kvstore_bd_read_size</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef uint32_t(* mtb_kvstore_bd_read_size) (void *context, uint32_t addr)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Function prototype to get the read size of the block device for a specific address. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">context</td><td>Context object that is passed into <a class="el" href="group__group__kvstore.html#ga51e164317709c8d0c02fc07d87e4e780">mtb_kvstore_init</a> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>Address for which the read size is queried. This address is passed in as start_addr + offset. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Read size of the memory device. </dd></dl>

</div>
</div>
<a id="ga33782352587721d63e4ca26f35558d90" name="ga33782352587721d63e4ca26f35558d90"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga33782352587721d63e4ca26f35558d90">&#9670;&nbsp;</a></span>mtb_kvstore_bd_program_size</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef uint32_t(* mtb_kvstore_bd_program_size) (void *context, uint32_t addr)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Function prototype to get the program size of the block device for a specific address. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">context</td><td>Context object that is passed into <a class="el" href="group__group__kvstore.html#ga51e164317709c8d0c02fc07d87e4e780">mtb_kvstore_init</a> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>Address for which the program size is queried. This address is passed in as start_addr + offset. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Program size of the memory device. </dd></dl>

</div>
</div>
<a id="ga9dcd451cefcdae7d7063aa2e173b948b" name="ga9dcd451cefcdae7d7063aa2e173b948b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9dcd451cefcdae7d7063aa2e173b948b">&#9670;&nbsp;</a></span>mtb_kvstore_bd_erase_size</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef uint32_t(* mtb_kvstore_bd_erase_size) (void *context, uint32_t addr)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Function prototype to get the erase size of the block device for a specific address. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">context</td><td>Context object that is passed into <a class="el" href="group__group__kvstore.html#ga51e164317709c8d0c02fc07d87e4e780">mtb_kvstore_init</a> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>Address for which the erase size is queried. This address is passed in a start_addr + offset. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Erase size of the memory device. </dd></dl>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga51e164317709c8d0c02fc07d87e4e780" name="ga51e164317709c8d0c02fc07d87e4e780"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga51e164317709c8d0c02fc07d87e4e780">&#9670;&nbsp;</a></span>mtb_kvstore_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_init </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>start_addr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="group__group__kvstore.html#structmtb__kvstore__bd__t">mtb_kvstore_bd_t</a> *&#160;</td>
          <td class="paramname"><em>block_device</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize a instance kv-store library. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">obj</td><td>Pointer to a kv-store object. The caller must allocate the memory for this object but the init function will initialize its contents. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">start_addr</td><td>Start address for the memory. All addresses when performing memory operations will be offset from this address. See notes for constraints. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">length</td><td>Total space available in bytes. See notes for constraints. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">block_device</td><td>Block device interface for the underlying memory to be used.</td></tr>
  </table>
  </dd>
</dl>
<p>Address space considerations </p><dl class="section note"><dt>Note</dt><dd>The start_addr and start_addr + length must be aligned to the erase sector boundary. </dd>
<dd>
An even number of erase sectors must be provided as storage. (2 * N * erase sector size) where N is the number of sectors. </dd>
<dd>
The implementation assumes that the value of the storage in the erased state is either 0x00 or 0xFF. </dd>
<dd>
The space provided to the library provided must have the uniform characteristics (erase, program and read size). A space spanning regions with different characteristics in a hybrid sector device is not supported and if provided may lead to undefined behavior.</dd></dl>
<p>RTOS considerations </p><dl class="section note"><dt>Note</dt><dd>In a RTOS environment the library must be initialized after the RTOS kernel has started.</dd></dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the initialization operation. </dd></dl>

</div>
</div>
<a id="ga209eef7f4603173449de48d3d4775835" name="ga209eef7f4603173449de48d3d4775835"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga209eef7f4603173449de48d3d4775835">&#9670;&nbsp;</a></span>mtb_kvstore_write()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_write </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint8_t *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Store a key value pair. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">key</td><td>Lookup key for the data. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">data</td><td>Pointer to the start of the data to be stored. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">size</td><td>Total size of the data in bytes.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the write operation. </dd></dl>

</div>
</div>
<a id="gad2327026f8f741835d012aa0a1f60f14" name="gad2327026f8f741835d012aa0a1f60f14"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad2327026f8f741835d012aa0a1f60f14">&#9670;&nbsp;</a></span>mtb_kvstore_read()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_read </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t *&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Read data associated with a key. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">key</td><td>Lookup key for the data. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">data</td><td>Pointer to the start of the buffer for the data to be read into. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">size</td><td>[in] Total size of the data in bytes. [out] Actual size of the data in storage. If a data buffer is provided then the size cannot be NULL or 0.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>It is valid to set both <code>data</code> and <code>size</code> to NULL to check if the key exists in the storage.</dd></dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the read operation. </dd></dl>

</div>
</div>
<a id="gadd5125b0adf2ef5a4afc39851aeaa288" name="gadd5125b0adf2ef5a4afc39851aeaa288"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gadd5125b0adf2ef5a4afc39851aeaa288">&#9670;&nbsp;</a></span>mtb_kvstore_read_partial()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_read_partial </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t *&#160;</td>
          <td class="paramname"><em>size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint32_t&#160;</td>
          <td class="paramname"><em>offset_bytes</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Read data associated with a key. </p>
<p >If buffer is too small, will partially read and fill buffer. No corruption checking is performed.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">key</td><td>Lookup key for the data. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">data</td><td>Pointer to the start of the buffer for the data to be read into. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">size</td><td>[in] Total size of the data in bytes. [out] Number of bytes read into buffer. If a data buffer is provided then the size cannot be NULL or 0. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">offset_bytes</td><td>Number of bytes to skip at the start the value read into data</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the read operation. </dd></dl>

</div>
</div>
<a id="ga16b0bc2c58f9a4259d295746df43c8ad" name="ga16b0bc2c58f9a4259d295746df43c8ad"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga16b0bc2c58f9a4259d295746df43c8ad">&#9670;&nbsp;</a></span>mtb_kvstore_key_exists()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_key_exists </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>key</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Check if a key is stored in memory. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">key</td><td>Lookup key</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the key_exists operation </dd></dl>

</div>
</div>
<a id="gafd3c856a28b4a326f6e2982f0d18b6dc" name="gafd3c856a28b4a326f6e2982f0d18b6dc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gafd3c856a28b4a326f6e2982f0d18b6dc">&#9670;&nbsp;</a></span>mtb_kvstore_value_size()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_value_size </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t *&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the size in bytes of data in memory corresponding to a given key. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">key</td><td>Lookup key for the data </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">size</td><td>Size of data in bytes</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the value size operation </dd></dl>

</div>
</div>
<a id="gafb22467328e29fd0b881eae93679a0f9" name="gafb22467328e29fd0b881eae93679a0f9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gafb22467328e29fd0b881eae93679a0f9">&#9670;&nbsp;</a></span>mtb_kvstore_delete()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_delete </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>key</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Delete a key value pair. </p>
<dl class="section note"><dt>Note</dt><dd>This function will return CY_RSLT_SUCCESS if the key cannot be found in the storage.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">key</td><td>Lookup key to delete key value pair.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the delete operation. </dd></dl>

</div>
</div>
<a id="ga543e217c6dad81778e1fc9926e28f23f" name="ga543e217c6dad81778e1fc9926e28f23f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga543e217c6dad81778e1fc9926e28f23f">&#9670;&nbsp;</a></span>mtb_kvstore_size()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t mtb_kvstore_size </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Query the size consumed in the kv-store storage. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Size of storage consumed in bytes. </dd></dl>

</div>
</div>
<a id="ga51591921642d49be5e5c8a9814bebd39" name="ga51591921642d49be5e5c8a9814bebd39"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga51591921642d49be5e5c8a9814bebd39">&#9670;&nbsp;</a></span>mtb_kvstore_remaining_size()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t mtb_kvstore_remaining_size </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Query the free space available in the kv-store storage. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Size of storage free in bytes. </dd></dl>

</div>
</div>
<a id="gad0c50e719da0063d48d9d6224d22c756" name="gad0c50e719da0063d48d9d6224d22c756"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad0c50e719da0063d48d9d6224d22c756">&#9670;&nbsp;</a></span>mtb_kvstore_ensure_capacity()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_ensure_capacity </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Tries to make the specified amount of space available for immediate use. </p>
<p >If necessary, internal cleanup operations will be executed to make additional space available, so this is a potentially long-running operation.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">size</td><td>Amount of space to ensure is available, in bytes. To always perform cleanup operations regardless of the amount of space currently free, use <a class="el" href="group__group__kvstore.html#gab15b7f2a1cea77f4621f72c8082ae352">MTB_KVSTORE_ENSURE_MAX</a>.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the operation. If <code>size</code> is not <a class="el" href="group__group__kvstore.html#gab15b7f2a1cea77f4621f72c8082ae352">MTB_KVSTORE_ENSURE_MAX</a> and it is not possible to make the requested amount of space available, returns <a class="el" href="group__group__kvstore.html#gaf746e26fd8da70e4169614b530371a65">MTB_KVSTORE_STORAGE_FULL_ERROR</a>. </dd></dl>

</div>
</div>
<a id="ga5dc849717a6e3c8b7803fe2224cc6df1" name="ga5dc849717a6e3c8b7803fe2224cc6df1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5dc849717a6e3c8b7803fe2224cc6df1">&#9670;&nbsp;</a></span>mtb_kvstore_reset()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_reset </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reset kv-store storage. </p>
<p >This function erases all the data in the storage.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the reset operation </dd></dl>

</div>
</div>
<a id="ga4388f0dd869ef9dbe2da0d2920cca290" name="ga4388f0dd869ef9dbe2da0d2920cca290"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4388f0dd869ef9dbe2da0d2920cca290">&#9670;&nbsp;</a></span>mtb_kvstore_deinit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mtb_kvstore_deinit </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Delete kv-store instance. </p>
<p >This function frees any program memory allocated by the library.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>Key Value Storage (kv-store)</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
